package Servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
 *
 * 用户退出主页功能实现
 * 登录成功后 退出功能实现:
 * 将存在session中的对象移除掉
 * 跳回到登录页面
 *
 * */
@WebServlet(name = "UserExitServlet", urlPatterns = "/userExistServlet")
public class UserExitServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // request.getParameterValues("");
            //移除session对象
        request.getSession().removeAttribute("login");
        //跳回登录页面
        request.getRequestDispatcher("/login.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
